package com.learn.xiaoha.SimpleFactoryBean;

import com.learn.xiaoha.ProxyMapper.ProxyMapper;
import org.springframework.beans.factory.FactoryBean;

/**
 * SimpleFactoryBean
 *
 * @author: cyx_jay
 * @date: 2021/2/3 17:54
 */
public class SimpleFactoryBean<T> implements FactoryBean<T> {
    private Class<T> aClass;

    private static ProxyMapper proxyMapper = new ProxyMapper();
    @Override
    public T getObject() throws Exception {
        return proxyMapper.getProxyMapper(aClass);
    }

    @Override
    public Class<?> getObjectType() {
        return aClass;
    }

    public Class getaClass() {
        return aClass;
    }

    public void setaClass(Class aClass) {
        this.aClass = aClass;
    }

    public static ProxyMapper getProxyMapper() {
        return proxyMapper;
    }

    public static void setProxyMapper(ProxyMapper proxyMapper) {
        SimpleFactoryBean.proxyMapper = proxyMapper;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}
